package com.woniuxy.controller;

import com.woniuxy.entity.RbacManager;
import com.woniuxy.entity.ResponseEntity;
import com.woniuxy.service.RbacManagerService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/rbacManager")
public class RbacManagerController {
    @Autowired(required = false)
    RbacManagerService rbacManagerService;

    @PostMapping("/findAll/{currentPage}/{pageSize}")
    @RequiresPermissions("user_manager")
    public ResponseEntity findAll(@PathVariable("currentPage") int currentPage,
                                  @PathVariable("pageSize") int pageSize, @RequestBody RbacManager rbacManager) {
        return rbacManagerService.findAll(currentPage,pageSize,rbacManager);
    }

    @DeleteMapping("/deleteOne/{id}")
    public ResponseEntity deleteOne(@PathVariable int id){
        return rbacManagerService.deleteOne(id);
    }


    @RequestMapping("/addOne")
    public ResponseEntity addOne(RbacManager rbacManager){
        return rbacManagerService.addONE(rbacManager);
    }

    @RequestMapping("/updateOne")
    public ResponseEntity UpdateOne(int id){
        return  rbacManagerService.updateOne(id);
    }
}
